<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
<link href="${ctx}/styles/aux_window.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>
<%@include file="/commons/commonList.jsp" %>
<%@include file="coWorkerSelectInclude.jsp" %>

<script type="text/javascript">
	function  save(){
		var selectValue = getSelectValue();
		if(selectValue == null || selectValue == "") {
			windowClose();
			return;
		}
		var url = "${ctx}/house_projectAction.do?method=addCoWorkerToProjectForSession";
		var str = "coworkerIds=" + selectValue + "&coworkType=${coWorkerType}";
		setButtonUnUseable();
		new Ajax.Request(url,
	                    {method: 'post', parameters: str, onComplete:function(result){
	                    												setButtonUseable();
	                    												ajaxSubmitException(result.responseText);
	                    												flushSelectedList();
	                    												}}
	                    );

	}

	function flushSelectedList(){
		var frameName = "${empty isArea ? 'projectInfo' : 'areaInfoIframe'}";
		findFrame(frameName).reloadFrame('${coWorkerType}');
		windowClose();
	}
	//设置按钮不可用
	function setButtonUnUseable(){
		document.getElementById("btn1_22").disabled = true;
		document.getElementById("btn1_32").disabled = true;
	}
	//设置按钮可用
	function setButtonUseable(){
		document.getElementById("btn1_22").disabled = false;
		document.getElementById("btn1_32").disabled = false;
	}
	/**
	* 获取选择的值
	**/
	function getSelectValue(){
		var checkboxs = document.getElementsByTagName("INPUT");
		var regExp = /\d*/;

		var selectValue = new Array();
		for(i = 0; i < checkboxs.length; i++){
			if(checkboxs[i].type == "checkbox" && checkboxs[i].status && isDigit(checkboxs[i].value)){
				selectValue[selectValue.length] = checkboxs[i].value;
			}
		}

		return selectValue.toString();
	}
	//判断
	function isDigit(obj){
		var r,re;
		re = /\d*/i; //\d表示数字,*表示匹配多个数字
		r = obj.match(re);
		return (r==obj)?true:false;
	}
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td>
        	<img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle">
        	<span class="window_head_intext">${title}</span>
        </td>
       </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
    <tr>
      <td  class="content">
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="aux_outtable_color">
      		<tr>
        		<td>
        			<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tab_line">
                        <tr>
                            <td valign="top">
								<table width="100%" border="0" cellspacing="0" cellpadding="0" >
          							<tr>
            							<td colspan="5" >
											<div id="tab_subMenu5" style="height:160px;overflow:auto;">
													<ec:ceTable items="coworkList"
																autoIncludeParameters="true"
																var="coworkItem"
																action=""
																rowsDisplayed="3"
																width="100%"
																view="pmsview"
																styleClass="gridData"
															>
															<ec:ceRow styleClass="grid" id="${coworkItem.coWorkerID}">
																<ec:ceColumn property="#" headerCell="checkboxHeader" width="5%" cell="checkbox" value="${coworkItem.coWorkerID}"></ec:ceColumn>
																<ec:ceColumn property="name" headerCell="pmsHeadrCell" width="25%" title="${name}"></ec:ceColumn>
																<ec:ceColumn property="contactor" headerCell="pmsHeadrCell"  width="25%"  title="${contactor}"></ec:ceColumn>
																<ec:ceColumn property="address" headerCell="pmsHeadrCell"   width="25%" title="${address}"></ec:ceColumn>
																<ec:ceColumn property="telephone" headerCell="pmsHeadrCell" width="25%" title="${telephone}"></ec:ceColumn>
															</ec:ceRow>
													</ec:ceTable>
												</div>
      </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </td>
    </tr>
  <tr>
    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onClick="save();" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onblur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom"> 确 定</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onblur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom"> 取 消</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>